<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">
	<span class="color_red">*</span>产学研合作项目基本情况
</div>
<table id="budgetFunds"  border="0" cellspacing="0" cellpadding="0" class="table01" >
<tr>
<td width="14%" align="right">申请资助金额：
  <td width="86%" >
	<input name="proposal/budget_funds" class="input_text required percentCompare:zh_projects_total_actually_amt:50 max:50" style="text-align:right;" id="budget_funds"
		label="申请资助金额" onfocus="InitInput.setNumber(this,7,4,2)" value="<x:out select="$xmlData/data/proposal/budget_funds" />">万元
</td>
</tr>
</table>
	<table id="zh_projects" border="0" cellspacing="0" cellpadding="0" class="table01" >
		<thead>
			<tr>
                <th width="7%" >选择</th>
                <th width="7%" nowrap>序号</th>
				<th width="17%">具体项目名称</th>
				<th width="17%">合作单位名称</th>
				<th width="15%">合作形式</th>
				<th width="11%">合作协议签订时间</th>
				<th width="13%">项目资金投入金额<br>（万元）</th>
				<th width="13%" >实际支付合作方金额<br>（万元）</th>
			</tr>
		</thead>
		<tbody id="tab">
			<tr style="display: none">
				<td  align="center" >
					<input type="hidden" name='zh_projects|zh_project[0]|prp_imple'/>
					<input type="hidden" name='zh_projects|zh_project[0]|prp_ebenefit'/>
					<input type="hidden" name='zh_projects|zh_project[0]|prp_sbenefit'/>
					<input type="hidden" name='zh_projects|zh_project[0]|prp_imple_hidden'/>
					<input type="hidden" name='zh_projects|zh_project[0]|prp_ebenefit_hidden'/>
					<input type="hidden" name='zh_projects|zh_project[0]|prp_sbenefit_hidden'/>
					<input type="radio" name="sel_zh_projects" class="radiobutton" /> 
				</td>
				<td align="center">
					<span name="zh_projects|zh_project[0]@seq_no">[index]</span>
				</td>
				<td>
					<span name="zh_projects|zh_project[0]|plan_name"></span>
				</td>
				<td>
					<span name="zh_projects|zh_project[0]|prp_name"></span>
				</td>
				<td align="center">
					<span name="zh_projects|zh_project[0]|dept"></span>
				</td>
				<td align="center">		
					<span name="zh_projects|zh_project[0]|year"></span>
				</td>
				<td align="right">
					<span name="zh_projects|zh_project[0]|amt"></span>
				</td>
				<td align="right">					
					<span name="zh_projects|zh_project[0]|actually_amt"></span>
				</td>
			</tr>
			<c:set value="0" var="index" scope="page" />
			<x:forEach select="$xmlData/data/zh_projects/zh_project" var="zh_project">
				<c:choose>
					<c:when test="${index<10}">
						<c:set value="0" var="flag" scope="page" />
					</c:when>
					<c:otherwise>
						<c:set value="" var="flag" scope="page" />
					</c:otherwise>
				</c:choose>
				<tr>
					<td  align="center" >
						<input type="hidden" name='zh_projects/zh_project[${flag}${index}]/prp_imple' value="<x:out select="$zh_project/prp_imple"/>"/>
						<input type="hidden" name='zh_projects/zh_project[${flag}${index}]/prp_ebenefit' value="<x:out select="$zh_project/prp_ebenefit"/>"/>
						<input type="hidden" name='zh_projects/zh_project[${flag}${index}]/prp_sbenefit' value="<x:out select="$zh_project/prp_sbenefit"/>"/>
						<input type="hidden" name='zh_projects/zh_project[${flag}${index}]/prp_imple_hidden' value="<x:out select="$zh_project/prp_imple_hidden"/>"/>
						<input type="hidden" name='zh_projects/zh_project[${flag}${index}]/prp_ebenefit_hidden' value="<x:out select="$zh_project/prp_ebenefit_hidden"/>"/>
						<input type="hidden" name='zh_projects/zh_project[${flag}${index}]/prp_sbenefit_hidden' value="<x:out select="$zh_project/prp_sbenefit_hidden"/>"/>
						<input type="radio" name="sel_zh_projects" class="radiobutton" /> 
					</td>
					<td align="center">
					    <span name="zh_projects/zh_project[${flag}${index}]@seq_no">${index+1}</span>
					</td>
					<td>
					    <span name="zh_projects/zh_project[${flag}${index}]/plan_name"><x:out select="$zh_project/plan_name" /></span>
					</td>
					<td>
					    <span name="zh_projects/zh_project[${flag}${index}]/prp_name"><x:out select="$zh_project/prp_name" /></span>
					</td>
					<td align="center">
					    <span name="zh_projects/zh_project[${flag}${index}]/dept"><x:out select="$zh_project/dept" /></span>
					</td>
					<td align="center">	
					    <span name="zh_projects/zh_project[${flag}${index}]/year"><x:out select="$zh_project/year" /></span>
					</td>
					<td align="right">
					    <span name="zh_projects/zh_project[${flag}${index}]/amt"><x:out select="$zh_project/amt" /></span>
					</td>
					<td align="right">					
					    <span name="zh_projects/zh_project[${flag}${index}]/actually_amt"><x:out select="$zh_project/actually_amt" /></span>
				    </td>
				</tr>
				<c:set value="${index+1}" var="index" scope="page" />
			</x:forEach>
			</tbody>
	</table>
    <table id="zh_projects_total" border="0" cellspacing="0" cellpadding="0" class="table01"  style="display: none">
		<thead>
			<tr>
                <td width="87%" style="text-align:right;">合计</td>
                <td width="13%"  align="center">					
					<input name="zh_projects_total/actually_amt" id="zh_projects_total_actually_amt"
					       class="input_text gray" style="text-align:right;width:80%" 
					       label="实际到账金额（万元）" onfocus="InitInput.setNumber(this,7,4,2)" disabled
					       value="<x:out select="$xmlData/data/zh_projects_total/actually_amt" />">
				</td>
			</tr>
		</thead>
	</table>
	<br>
	<table border="0" cellpadding="0" cellspacing="1">
		<tr>
			<td>
				&nbsp;<input class="button" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('zh_projects',10,'只能填写10个产学研合作项目基本情况 ')){addNewRow('zh_projects','${ctx}/proposal/edit/dialog/prpInfoEdit_cxyhz?parentTab=zh_projects&type=add&TB_iframe=true&height=440&width=900','添加产学研合作项目情况 ');}try{top.resizeFrame();}catch(e){};">
				&nbsp;<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev('zh_projects','sel_zh_projects')">
				&nbsp;<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext('zh_projects','sel_zh_projects')">
				&nbsp;<input class="button"  id="zh_psnEdit" type="button" value="编辑" onclick="editRow('zh_projects','${ctx}/proposal/edit/dialog/prpInfoEdit_cxyhz?parentTab=zh_projects&type=edit&needMeetingInfo=${param.needMeetingInfo}&TB_iframe=true&height=440&width=900','编辑产学研合作项目情况信息')">
				&nbsp;<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('zh_projects','产学研合作项目基本情况 ');countTableSpan('zh_projects','zh_projects_total_amt','6');countTableSpan('zh_projects','zh_projects_total_actually_amt','7');displayTotal('zh_projects','zh_projects_total');">
			</td>	
		</tr>
		</tbody>
		<tfoot>
		</tfoot>
	</table>
	
	<script type="text/javascript">
	    $(function() {
	    	displayTotal('zh_projects','zh_projects_total');
	    });
	    function displayTotal(tabel1,tabel2){
	    	var len = $("#"+tabel1+" tr").length-2;
	    	if(len>=1){
	    		$("#"+tabel2).attr("style","display: ''");
	    	}else{
	    		$("#"+tabel2).attr("style","display: none");
	    	}
	    }
	    function addNewRowDeal(table)
	    {
	    	var maxLinNum=table.find("tr").length-2;;//获得行数，减去表头和隐藏行
	    	var lineNum=""+(maxLinNum+1);
	    	
	    	var addHtml=table.find("tr")[1].innerHTML;//获得隐藏行的html,查找第二行
	    	addHtml=addHtml.replace(/\[index\]/g,lineNum);
	    	lineNum = (parseInt(lineNum, 10)-1).toString();//2011.12.13 行下标比行号小1(隐藏行下标[0]，第一行下标[00])
	    	if (lineNum.length==1)//如果是个位数，前面补0
	    		lineNum="0"+lineNum;
	    	addHtml=addHtml.replace(/\[0\]/g,"["+lineNum+"]");//替换html中行号
	    	addHtml=addHtml.replace(/\|/g,"/");//替换html中节点/的代替符"|"
	    	addHtml=addHtml.replace(/\(0\)/g,"\\["+lineNum+"\\]:50");
	    	table.append("<tr>"+addHtml+"</tr>");//将html增加到最后
	    	
	    }
	    function irisValMax(len, obj) {
	    	var str = getTagValueByJq(obj);
            var max = "[name]的值不能大于[money]万元"
	    	// str=str.replace(/\r(\n)?/g,"");

	    	if (parseInt(str) > len) {
	    		var strLaber = "";
	    		if (obj.attr("label") != null) {
	    			strLaber = obj.attr("label");
	    		}
	    		irisValaddMsg(max.replace("[name]", strTitle + strLaber).replace("[money]", len));
	    		return false;
	    	}
	    	return true;
	    }
    </script>
